<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page language="java" import="java.util.*,java.text.SimpleDateFormat, com.bean.library.StatisticPaper,
	com.bean.library.Course, com.bean.library.Teacher,com.bean.library.Paper, com.bean.library.Subject ,
	com.bean.library.Option,com.bean.library.UserOption"%>
<jsp:useBean id="teacher" class="com.bean.library.Teacher" scope="session"></jsp:useBean>
<jsp:useBean id="paper" class = "com.bean.library.Paper" scope="session"></jsp:useBean>
<jsp:useBean id="partialPaper" class = "com.bean.library.Paper" scope="session"></jsp:useBean>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
	String teacherName = teacher.getTeacherName();	//教师名
	//试卷相关
	String paperTitle = partialPaper.getPaperName();
	int startIndex = partialPaper.getStartIndex();
	int prePageNum = startIndex;
	int nextPageNum = startIndex + 2;
	int curPageNum = startIndex + 1; 
	int totalSize = paper.getSubjectList().size();
	int maxPageNum = (totalSize%10==0)?(totalSize/10):(totalSize/10 + 1);
	//获取session
	HttpSession s = request.getSession();
%>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Paper Content</title>
    <link rel="stylesheet" href="../t_css/t_common.css" type="text/css" />
    <link rel="stylesheet" href="../t_css/t_left_course.css" type="text/css" />
    <link rel="stylesheet" href="../t_css/t_paperContent.css" type="text/css" />
    <script type="text/javascript" src="../scripts/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../scripts/jquery.animate-colors-min.js"></script>
    <script type="text/javascript" src="../t_scripts/t_navi_common.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#choose_logo").hover(function () {
                $(this).animate({ backgroundColor: '#30A8F4' }, { speed: 1000, queue: false });
            }, function () {
                $(this).animate({ backgroundColor: '#C35A33' }, { speed: 1000, queue: false });
            });
            var btns = ["btn_exam_info", "btn_convert", "btn_check_content"];
            var oldColor;
            $(btns).each(function (key,value) {
                $("." + value).hover(function () {
                    oldColor = $(this).css('background-color');
                    $(this).animate({ backgroundColor: '#30A8F4' }, { speed: 1000, queue: false });
                }, function () {
                    $(this).animate({ backgroundColor: oldColor }, { speed: 1000, queue: false });
                });
            });

            var up_hrefColor = $("#href_up").css('color');
            var down_hrefColor = $("#href_down").css('color');
            $("#page_up").hover(function () {
            	$("#submit_page_num").val(parseInt($("#page_num").val(),10)-1);
                $("#href_up").animate({ color: '#000000' }, 0);
            }, function () {
                $("#href_up").animate({ color: up_hrefColor }, 0);
            });

            /**********  判断翻页      *************/
            $("#page_down").hover(function () {
            	$("#submit_page_num").val(parseInt($("#page_num").val(),10)+1);
                $("#href_down").animate({ color: '#000000' }, 0);
            }, function () {
                $("#href_down").animate({ color: down_hrefColor }, 0);
            });
            
            var page_num = parseInt($("#page_num").val(),10);
            var max_page_num = parseInt($("#max_page_num").val(),10);
            
            $("#page_up").click(function(){
            	if(page_num <= 1){
            		return false;
            	}
            	$("#submit_form").submit();
            });
            $("#page_down").click(function(){
            	if(page_num >= max_page_num){
            		return false;
            	}
            	$("#submit_form").submit();
            });
        });
    </script>
</head>
<body>
<div id="bigContent">
<div id="head">
    <div id="title">
        <div class="title_left">
            <div class="titleText">Students Online Exam Platform ( For Teacher )</div>
        </div>
        <div class="title_right">
            <div class="avatar"><img src="../image/noavatar.jpg" alt="../image/noavatar.jpg"/></div>
            <div class="userState">
                <div class="userState_big"><a href="#"><%=teacherName %></a></div>
                <div class="userState_small"><a href="/Exam1/servlet/TLogoutServlet">logout</a></div>
            </div>
        </div>
    </div>
    <div id="navi">
    <form id="navi_form" action="/Exam1/servlet/TNaviSelectServlet" method="post">
        <div class="navi_top">
            <ul class="all_navi">
            	<li id="navi1" class="each_navi navi1">Set Questions</li>
                <li id="navi2" class="each_navi navi2">Check Paper</li>
            </ul>
        </div>
        <div class="navi_bottom">
            <ul class="all_courses">
            	<%
            	ArrayList<Course> teacherCourseList = teacher.getTeacherCourseList();
            	Iterator<Course> teacherCourseIt = teacherCourseList.iterator();
            	int courseNum = 0;
            	while(teacherCourseIt.hasNext()){
            		courseNum++;
            		Course course = teacherCourseIt.next();
            		String courseName = course.getCourseName();
            		String courseId = course.getCourseId();
            	
            	%>
            	<li class="each_course course<%=courseNum%>" id="<%=courseId%>"><%=courseName %></li>
            	<%} %>
            </ul>
        </div>
        <input type="hidden" id="operate_type" name="operate_type" value=""/>
        <input type="hidden" id="course_id" name="course_id" value=""/>
        <input type="hidden" id="course_name" name="course_name" value=""/>
    </form> 
    </div>
</div>
<div id="content_exam"  class="boxShadow">
    <div id="choose_logo">
        <div class="choose_logo_text">Check Paper</div>
        <div class="choose_logo_img"></div>
    </div>
    <div id="content_left">
        <div id="courses">
            <div id="courses_title">Courses</div>
            <form id="course_form" action="/Exam1/servlet/TCourseSelectServlet" method="post">
	            <div id="courses_details">
	                <ul id="courses_list">
	                	<%  courseNum = 0;
	                		Iterator<Course> teacherCourseIt1 = teacherCourseList.iterator();
	                		while(teacherCourseIt1.hasNext()){
	                		courseNum++;
	                		Course course = teacherCourseIt1.next();
	                		String courseName = course.getCourseName();
	                		String courseId = course.getCourseId(); %>
	                    <li class="li<%=courseNum%>" id="<%=courseId%>"><div class="each_course_text"><%=courseName %></div></li>
	                    <%} %>
	                </ul>
	                <input type="hidden" id="li_count" value="<%=courseNum%>"/>
	            </div>
	           	<input type="hidden" value="" id="select_course" name="select_course"/>
	            <input type="hidden" value="" id="select_course_name" name="select_course_name"/>
	            <input type="hidden" value="checkpaper" id="test_type" name="operate_type"/>
            </form>
        </div>
    </div>
    <div id="content_right">
    	<%   		
    		String courseName = (String)s.getAttribute("selectedCourseName");
		%>     
        <div id="subjects_name"><%=courseName %></div>
        <div id="paper_name" class="paper_name"><%=paperTitle%></div>
    	<%
    		ArrayList<Subject> subList = partialPaper.getSubjectList();
			Iterator<Subject> subIt = subList.iterator();
    		int subNum = 0;
    		while (subIt.hasNext())
    		{
    			subNum++;
    			int subNo = startIndex*10 + subNum; 
    			Subject sub = (Subject)subIt.next();
               	ArrayList<Option> optList = sub.getOptList();
               	Iterator<Option> optIt = optList.iterator();
    	%>        
        <div class="subject">
            <div class="subject_title"><%=subNo+"."+sub.getSubjectContent() %></div>
            <div class="opts">
                <%       	
                	int optNum = 0;
                	while(optIt.hasNext()){
                		char optChar = (char)(optNum+65);
                		UserOption opt = (UserOption)optIt.next();
                		String optContent = opt.getOptContent();
                		char mark = 'T';
                		if(opt.isChecked()){
                			mark = 'T';
                		}
                		else{
                			mark = 'F';
                		}
                %>            
                <div class="each_opt"><%=optChar+"."+optContent+" "+mark%></div>
                <%} %>
            </div>
        </div>
        <%} %>
        <div id="page_turning">
            <div id="page_up_down">
                <div id="page_up">
                    <div id="page_up_text">previous page</div>
                </div>
                <div id="page_down">
                    <div id="page_down_text">next page</div>
                </div>
                <form id="submit_form" action="/Exam1/servlet/TCheckPaperContentListServlet" method="get">
	               	<input id="page_num" name="page_num" type="hidden" value="<%=curPageNum%>"/>
		            <input id="max_page_num" type="hidden" value="<%=maxPageNum%>"/>
		            <input id="submit_page_num" name="submit_page_num" type="hidden" value=""/>
	            </form>              
            </div>
        </div>
    </div>
    <div id="content_bottom"></div>   
</div>
</div>
</body>
</html>